/**
 * Copyright (c) OpenLens Authors. All rights reserved.
 * Licensed under MIT License. See LICENSE in root directory for more information.
 */

import { Common } from "@k8slens/extensions";
import { observable, makeObservable } from "mobx";

export type NodeShellPreferencesModel = {
  customImage: string;
  imagePullSecret: string;
  namespace: string;
};

export class NodeShellPreferencesStore extends Common.Store
  .ExtensionStore<NodeShellPreferencesModel> {
    
  @observable customImage = "cce.ghac.cn/oaimages/alpine:3.16";
  @observable imagePullSecret = "default-secret";
  @observable namespace = "default";

  constructor() {
    super({
      configName: "node-shell-preference-store",
      defaults: {
        customImage: "cce.ghac.cn/oaimages/alpine:3.16",
        imagePullSecret: "default-secret",
        namespace: "default",
      },
    });
    makeObservable(this);
  }

  fromStore({ customImage, imagePullSecret, namespace }: NodeShellPreferencesModel): void {
    this.customImage = customImage;
    this.imagePullSecret = imagePullSecret;
    this.namespace = namespace;
  }

  toJSON(): NodeShellPreferencesModel {
    return {
      customImage: this.customImage,
      imagePullSecret: this.imagePullSecret,
      namespace: this.namespace,
    };
  }
}

export const nodeShellPreferencesStore = new NodeShellPreferencesStore();